package com.leoman.spinningmachine.tab2;

import android.content.Context;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.leoman.helper.adapter.BaseRecyclerAdapter;
import com.leoman.helper.util.FrescoUtil;
import com.leoman.spinningmachine.R;
import com.leoman.spinningmachine.bean.CardRecordBean;
import com.leoman.spinningmachine.util.DateUtil;

import java.util.List;

/**
 * Created by Administrator on 2018-06-05.
 */

public class CardDetailAdapter2 extends BaseRecyclerAdapter<CardRecordBean> {

    private Context mContext;

    public CardDetailAdapter2(Context context, int layoutResId, List data) {
        super(layoutResId, data);
        this.mContext = context;
    }

    @Override
    protected void bindTheData(BaseViewHolder holder, CardRecordBean bean, int position) {
        TextView tv_head = (TextView) holder.findViewById(R.id.tv_head);
        SimpleDraweeView iv_pic = (SimpleDraweeView) holder.findViewById(R.id.iv_pic);
        TextView tv_card_title = (TextView) holder.findViewById(R.id.tv_leave_title);
        TextView tv_msg_title = (TextView) holder.findViewById(R.id.tv_msg_title);
        TextView tv_msg_time = (TextView) holder.findViewById(R.id.tv_msg_time);
        TextView tv_sb_time = (TextView) holder.findViewById(R.id.tv_sb_time);
        TextView tv_address = (TextView) holder.findViewById(R.id.tv_address);

        tv_head.setText("" + DateUtil.getyMdHms(bean.getTime(), "MM月dd日 HH:mm"));
        FrescoUtil.setImg(mContext, iv_pic, bean.getHeadImage());
        tv_card_title.setText("考勤打卡");
        String sxstatus = "";

        tv_msg_title.setText(DateUtil.getyMdHms(bean.getTime(), "HH:mm") + "打卡 " + sxstatus);
        tv_msg_time.setText("" + DateUtil.getyMdHms(bean.getTime(), "MM月dd日"));
        if (bean.getTypeName().equals("早")) {
            tv_sb_time.setText("班次时间:\n" + bean.getmStartTime() + "-" + bean.getmEndTime() + "早班");
        } else if (bean.getTypeName().equals("中")) {
            tv_sb_time.setText("班次时间:\n" + bean.getNoonStartTime() + "-" + bean.getNoonEndTime() + "中班");
        } else if (bean.getTypeName().equals("晚")) {
            tv_sb_time.setText("班次时间:\n" + bean.getNightStartTime() + "-" + bean.getNightEndTime() + "晚班");
        }
        tv_address.setText("打卡地点:" + bean.getAddr());
    }
}
